package queue;/*
 *@ 代阳敲的专属代码
 **/

public class MyQueue {
    static class  Node{
        int val;
        Node perNode;
        Node nextNode;
        public Node(int val) {
            this.val = val;
        }
    }
    Node head;
    Node last;
    int usSize=0;
    public boolean offer( int val) {
        Node node=new Node(val);
        if(head==null&&last==null) {
            head=node;
            last=node;
            usSize++;
            return true;
        } else {
            last.nextNode=node;
            last=node;
            usSize--;
            return  true;
        }
    }
    public  int poll() {
        if(head==null) {
            return -1000000;
        }
        if(head==last) {
            int reVal=head.val;
            head=null;
            last=null;
            return reVal;
        }
        int reVal=head.val;
        head=head.nextNode;
        head.perNode=null;
        return reVal;
    }
    public int peek() {
        if(head==null) {
            return -1000000;
        }
        int reVal=head.val;
        return reVal;
    }
    public int size() {
        return usSize;
    }
}
